package com.itheima.servlet.night;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletDemo04 extends HttpServlet {
    private int money = 1000;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getRequestURI();
        System.out.println(name);
        name = name.substring(name.lastIndexOf("/"));
        System.out.println(name);

        if (name.equals("/vip")) {
            System.out.println("原价为" + money + "折扣价为" + (money * 0.9));
        } else {
            System.out.println("原价为" + money);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
